import { fileURLToPath, URL } from 'node:url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'node:path';
import CopyPlugin from 'vite-copy-plugin';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    CopyPlugin([
      { from: './src/manifest.json', to: './dist/manifest.json' },
      { from: './src/global', to: './dist/global' },
      { from: './src/logo', to: './dist/logo' }
    ])
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  base: './',
  build: {
    // 禁用压缩报告
    reportCompressedSize: false,
    assetsDir: 'assets',
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'popup.html'),
        options: resolve(__dirname, 'options.html')
      }
    }
  }
});
